﻿using IM.Easy.Core.Audit;
using SqlSugar;

namespace IM.Easy.Entity.System
{
    /// <summary>
    /// 字典类型表
    /// </summary>
    [SugarTable(TableDescription = "字典类型表")]
    [SugarIndex("index_dict_type", nameof(Code), OrderByType.Asc, true)]
    public class SysDictType : AuditSnowflakeEntity, ISystem, IActive
    {
        public SysDictType()
        {
            IsActive = true;
            IsSystem = false;
        }
        /// <summary>
        /// 字典编码
        /// </summary>
        [SugarColumn(Length = 100)]
        public string Code { get; set; }

        /// <summary>
        /// 字典名称
        /// </summary>
        [SugarColumn(Length = 100)]
        public string Name { get; set; }

        /// <summary>
        /// 启用状态
        /// </summary>
        public bool IsActive { get; set; }

        /// <summary>
        /// 是否系统内置
        /// </summary>
        public bool IsSystem { get; set; }

        /// <summary>
        /// 值类型
        /// </summary>
        public ValueDataType DataType { get; set; }

        /// <summary>
        /// 字典值
        /// </summary>
        [Navigate(NavigateType.OneToMany, nameof(SysDictData.Group), nameof(Code))]
        public List<SysDictData> Items { get; set; }
    }

    /// <summary>
    /// 值类型
    /// </summary>
    public enum ValueDataType
    {
        /// <summary>
        /// 字符串
        /// </summary>
        String,

        /// <summary>
        /// 数值
        /// </summary>
        Number,

        /// <summary>
        /// 布尔值
        /// </summary>
        Boolean,
    }
}
